package com.laiketui.plugin.common.mapper;

import com.laiketui.plugin.common.domain.base.CustomerModel;
import com.laiketui.plugin.common.tool.db.BaseMapper;
import com.laiketui.core.exception.LaiKeAPIException;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;


/**
 * 商城 sql
 *
 * @author Trick
 * @date 2020/11/11 9:09
 */
public interface CustomerModelMapper extends BaseMapper<CustomerModel> {
    @Override
    List<Map<String, Object>> selectDynamic(Map<String, Object> map) throws LaiKeAPIException;

    @Override
    int countDynamic(Map<String, Object> map) throws LaiKeAPIException;

    /**
     * 获取自营店id
     *
     * @param storeId -
     * @return Integer
     * @throws LaiKeAPIException -
     * @author Trick
     * @date 2021/3/23 9:58
     */
    @Select("select b.shop_id from lkt_customer as a left join lkt_admin as b on a.admin_id = b.id and b.store_id=a.id  where store_id = #{storeId}")
    Integer getStoreMchId(int storeId) throws LaiKeAPIException;

    /**
     * 获取自营店用户id
     *
     * @param storeId -
     * @return String
     * @throws LaiKeAPIException -
     * @author Trick
     * @date 2022-06-30 16:01:58
     */
    @Select("select m.user_id from lkt_customer as a left join lkt_admin as b on a.admin_id = b.id and b.store_id=a.id inner join lkt_mch m on m.id=b.shop_id  where a.id = #{storeId}")
    String getStoreUserId(int storeId) throws LaiKeAPIException;
}